package com.opmsys.service.impl;

import com.opmsys.mapper.WellMapper;
import com.opmsys.pojo.dto.WellPageDTO;
import com.opmsys.pojo.entity.Well;
import com.opmsys.service.WellService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 名称WellServiceImpl
 * 描述
 *
 * @version 1.0
 * @author:冉启呈2021015445
 * @datatime:2024-06-17 16:25
 */
@Service
public class WellServiceImpl implements WellService {

    @Autowired
    private WellMapper wellMapper;

    /**
     * 新增油井
     * @param well
     */
    public void addWell(Well well) {
        wellMapper.insertWell(well);
    }

    /**
     * 删除油井
     * @param id
     */
    public void deleteWells(Integer id) {
        wellMapper.deleteWell(id);
    }

    /**
     * 更新油井
     * @param well
     */
    public void updateWell(Well well) {
        wellMapper.updateWell(well);
    }

    /**
     * 查找油井
     * @param characteristic
     * @param type
     * @return
     */
    public List<Well> searchWells(String characteristic,Integer type){
        return wellMapper.searchWells(type, characteristic);
    }

    /**
     * 查找油井并分页
     * @param wellPageDTO
     * @return
     */
    public List<Well> pageWells(WellPageDTO wellPageDTO){
        return wellMapper.listWells(wellPageDTO.getType(),wellPageDTO.getCharacteristic(),wellPageDTO.getPageSize(),wellPageDTO.getPageSize()*(wellPageDTO.getPage()-1));
    }

    /**
     * 是否重名
     * @param name
     * @return
     */
    public List<Well> ifname(String name){
            return wellMapper.ifname(name);
        }
}
